﻿using AnesSystem.Controls;
using AnesSystem.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AnesSystem.ViewModels
{
    public class BaseDrugMethodCtrlViewModel : BaseViewModel<BaseDrugMethodCtrlViewModel>
    {
        #region Variables
        private PatientDrugsModel _patientDrugsModel;

        private ObservableCollection<ConfigUnitsModel> _unitsList;

        private BaseDrugMethodCtrl _baseDrugCtrl;
        #endregion

        #region Constructor
        public BaseDrugMethodCtrlViewModel()
        {
            
        }
     
        public PatientDrugsModel PatientDrugsModel
        {
            get
            {
                return MedicineConfigCtrlViewModel.Instance.PatientDrugsModelCopy;
            }

            set
            {
                _patientDrugsModel = value;
                RaisePropertyChanged("PatientDrugsModel");
            }
        }

        public ObservableCollection<ConfigUnitsModel> UnitsList
        {
            get
            {
                return DataManager.Instance.ConfigUnitsModelList;
            }

            set
            {
                _unitsList = value;
                RaisePropertyChanged("UnitsList");
            }
        }

        public BaseDrugMethodCtrl BaseDrugCtrl
        {
            get
            {
                return _baseDrugCtrl;
            }

            set
            {
                _baseDrugCtrl = value;
            }
        }


        #endregion

        #region Properties

        #endregion

        #region 依赖属性

        #endregion

        #region Event

        #endregion

        #region Private Methods

        #endregion

        #region Public/Protected Methods
        public void AddDrugSpeed(BaseDrugMethodCtrl baseCtrl)
        {
            baseCtrl.ListCtrl.Add(baseCtrl.CreateItem(new DrugSpeedModel(), true));            
        }

        public void DelDrugSpeed(BaseElementCtrl ctrl)
        {
            if (BaseDrugCtrl.ListCtrl.Count > 1)
            {
                BaseDrugCtrl.ListCtrl.Remove(ctrl);
                BaseDrugCtrl.PatientDrugs.DrugSpeeds.Remove(ctrl.DrugSpeed);
            }
        }
        #endregion

        #region EventHandlers

        #endregion
    }
}
